package mark.tom.detector;

import android.util.Log;

import mark.tom.detector.template.Logger;
import timber.log.Timber;

class TimberLogger implements Logger {

    private final static String TAG = "TimberLogger";

    private boolean onOff = true;

    @Override
    public void onOff(boolean on) {
        this.onOff = on;
    }

    @Override
    public void log(String message, int level) {
        if (!onOff) {
            return;
        }
        switch (level) {
            case Log.VERBOSE: {
                Timber.tag(TAG).v(message);
                break;
            }
            case Log.DEBUG: {
                Timber.tag(TAG).d(message);
                break;
            }
            case Log.INFO: {
                Timber.tag(TAG).i(message);
                break;
            }
            case Log.WARN: {
                Timber.tag(TAG).w(message);
                break;
            }
            case Log.ERROR: {
                Timber.tag(TAG).e(message);
                break;
            }
            default: {
                // ignore
            }
        }
    }
}
